package com.xjcs.saplingplan.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.xjcs.saplingplan.databinding.ItemMemoBgColorBinding

class MemoBgColorAdapter(
    private val context: Context,
    private val list: MutableList<Int>
): RecyclerView.Adapter<ItemMemoBgColorViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemMemoBgColorViewHolder {
        val binding = ItemMemoBgColorBinding.inflate(LayoutInflater.from(context), parent, false)
        return ItemMemoBgColorViewHolder(binding)
    }

    override fun getItemCount(): Int {
        return list.size
    }

    override fun onBindViewHolder(holder: ItemMemoBgColorViewHolder, position: Int) {
        val item = list[position]
        holder.bind(item)
    }
}

class ItemMemoBgColorViewHolder(val binding: ItemMemoBgColorBinding): RecyclerView.ViewHolder(binding.root){
    fun bind(color: Int){
        binding.bgView.setBgColor(color)
    }
}